<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.1.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/hexo/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/hexo/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/hexo/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/hexo/images/logo.svg" color="#222">

<link rel="stylesheet" href="/hexo/css/main.css">


<link rel="stylesheet" href="/hexo/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"youchen12138.gitee.io","root":"/hexo/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta property="og:type" content="website">
<meta property="og:title" content="幽辰的博客">
<meta property="og:url" content="https://youchen12138.gitee.io/hexo/page/12/index.html">
<meta property="og:site_name" content="幽辰的博客">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="幽辰">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://youchen12138.gitee.io/hexo/page/12/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'en'
  };
</script>

  <title>幽辰的博客</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/hexo/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">幽辰的博客</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/hexo/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/hexo/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>Tags<span class="badge">23</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/hexo/categories/" rel="section"><i class="fa fa-th fa-fw"></i>Categories<span class="badge">14</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/hexo/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives<span class="badge">127</span></a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="https://youchen12138.gitee.io/hexo/2020/08/26/CSS%E8%BF%9B%E9%98%B6%E7%9F%A5%E8%AF%86%E7%82%B9-%E5%8A%A8%E7%94%BB%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/hexo/images/avatar.jpg">
      <meta itemprop="name" content="幽辰">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="幽辰的博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/hexo/2020/08/26/CSS%E8%BF%9B%E9%98%B6%E7%9F%A5%E8%AF%86%E7%82%B9-%E5%8A%A8%E7%94%BB%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/" class="post-title-link" itemprop="url">CSS进阶知识点--动画性能优化</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>
              

              <time title="Created: 2020-08-26 00:07:13 / Modified: 00:09:37" itemprop="dateCreated datePublished" datetime="2020-08-26T00:07:13+08:00">2020-08-26</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/hexo/categories/CSS/" itemprop="url" rel="index"><span itemprop="name">CSS</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="目标"><a href="#目标" class="headerlink" title="目标"></a>目标</h1><p>增强页面渲染性能</p>
<h2 id="CPU-和-GPU"><a href="#CPU-和-GPU" class="headerlink" title="CPU 和 GPU"></a>CPU 和 GPU</h2><p>CPU 即中央处理器，解释计算机指令以及处理计算机软件中的数据</p>
<p>GPU 即图片处理器，专门处理和绘制图形相关的硬件。GPU 是专门执行复杂的数学和几何计算而设计的，有了它，CPU 就从图形处理的任务中解放出来，可以执行其他更多的系统任务</p>
<h2 id="现状"><a href="#现状" class="headerlink" title="现状"></a>现状</h2><p>CSS 的动画、变形、渐变并不会自动的触发 GPU 加速，而是使用浏览器稍慢的软件渲染引擎。</p>
<p>在 transition，transform 和 animation 的世界里，应该卸载进程到 GPU 以加快速度。</p>
<p>只有 3D 变形会有自己的 layer，2D变形不会</p>
<h2 id="translateZ-（or-translate3d-）Hack"><a href="#translateZ-（or-translate3d-）Hack" class="headerlink" title="translateZ()（or translate3d()）Hack"></a>translateZ()（or translate3d()）Hack</h2><p>为元素添加没有变化的 3D 变形，骗取浏览器触发硬件加速</p>
<h2 id="代价"><a href="#代价" class="headerlink" title="代价"></a>代价</h2><p>这种情况通过向它自己的层叠加元素，占用 RAM 和 GPU 存储空间</p>
<h1 id="will-change"><a href="#will-change" class="headerlink" title="will-change"></a>will-change</h1><p>提前通知浏览器元素将要做什么动画，让浏览器提前准备合适的优化设置</p>
<h2 id="语法"><a href="#语法" class="headerlink" title="语法"></a>语法</h2><blockquote>
<p>will-change：auto | scroll-position | contents | <code>&lt;custom-ident&gt;</code> | <code>&lt;animateable-feature&gt;</code></p>
</blockquote>
<h2 id="参数说明"><a href="#参数说明" class="headerlink" title="参数说明"></a>参数说明</h2><table>
<thead>
<tr>
<th>关键字</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>auto</td>
<td>此关键字表示没有特定的意图，适用于它通常所做的任何启发式和优化</td>
</tr>
<tr>
<td>scroll-position</td>
<td>表示将要改变元素的滚动位置</td>
</tr>
<tr>
<td>contents</td>
<td>表示将要改变元素的内容</td>
</tr>
<tr>
<td><code>&lt;custom-ident&gt;</code></td>
<td>明确指定将要改变的属性与给定的名称（最重要）</td>
</tr>
<tr>
<td><code>&lt;animateable-feature&gt;</code></td>
<td>可动画的一些特征值，比如left、top、margin等</td>
</tr>
</tbody></table>
<h2 id="使用注意"><a href="#使用注意" class="headerlink" title="使用注意"></a>使用注意</h2><ul>
<li><p>不能滥用</p>
</li>
<li><p>提前声明</p>
</li>
<li><p>remove</p>
</li>
</ul>
<p>尽量将 will-change 放在 hover 伪类的父元素里</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="https://youchen12138.gitee.io/hexo/2020/08/26/CSS%E8%BF%9B%E9%98%B6%E7%9F%A5%E8%AF%86%E7%82%B9-%E5%8A%A8%E7%94%BB%E5%8F%8A%E5%85%B3%E9%94%AE%E5%B8%A7/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/hexo/images/avatar.jpg">
      <meta itemprop="name" content="幽辰">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="幽辰的博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/hexo/2020/08/26/CSS%E8%BF%9B%E9%98%B6%E7%9F%A5%E8%AF%86%E7%82%B9-%E5%8A%A8%E7%94%BB%E5%8F%8A%E5%85%B3%E9%94%AE%E5%B8%A7/" class="post-title-link" itemprop="url">CSS进阶知识点--动画及关键帧</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>
              

              <time title="Created: 2020-08-26 00:04:45 / Modified: 00:05:46" itemprop="dateCreated datePublished" datetime="2020-08-26T00:04:45+08:00">2020-08-26</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/hexo/categories/CSS/" itemprop="url" rel="index"><span itemprop="name">CSS</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="动画"><a href="#动画" class="headerlink" title="动画"></a>动画</h1><h2 id="视觉暂留原理"><a href="#视觉暂留原理" class="headerlink" title="视觉暂留原理"></a>视觉暂留原理</h2><p>人类具有“视觉暂留”的特性，人的眼睛看到一幅画或一个物体后，在0.34秒内不会消失</p>
<h2 id="动画原理"><a href="#动画原理" class="headerlink" title="动画原理"></a>动画原理</h2><p>通过把人物的表情、动作、变化等分解后画成许多动作瞬间的画幅，利用视觉暂留的原理，在一幅画还没消失前播放下一幅画，就会给人一种流畅的视觉变化效果</p>
<h2 id="兼容性"><a href="#兼容性" class="headerlink" title="兼容性"></a>兼容性</h2><p>手机设备的浏览器在使用CSS3动画时，要加上-webkit-前缀</p>
<h2 id="CSS3-动画"><a href="#CSS3-动画" class="headerlink" title="CSS3 动画"></a>CSS3 动画</h2><p>使元素从一种样式逐渐变化成另一种样式的效果</p>
<h1 id="动画属性-animation"><a href="#动画属性-animation" class="headerlink" title="动画属性 animation"></a>动画属性 animation</h1><h2 id="animation-name-属性"><a href="#animation-name-属性" class="headerlink" title="animation-name 属性"></a>animation-name 属性</h2><p>检索或设置对象所应用的动画名称</p>
<h3 id="语法"><a href="#语法" class="headerlink" title="语法"></a>语法</h3><blockquote>
<p>animation-name: keyframename | none</p>
</blockquote>
<h3 id="参数说明"><a href="#参数说明" class="headerlink" title="参数说明"></a>参数说明</h3><p>keyframename：指定要绑定到选择器的关键帧的名称</p>
<p>noen：不规定动画</p>
<p>可以有多个值，每个值之间用“，”隔开</p>
<h2 id="animation-duration-属性"><a href="#animation-duration-属性" class="headerlink" title="animation-duration 属性"></a>animation-duration 属性</h2><p>检索或设置对象动画的持续时间</p>
<h3 id="语法-1"><a href="#语法-1" class="headerlink" title="语法"></a>语法</h3><blockquote>
<p>animation-duration: time</p>
</blockquote>
<h3 id="参数说明-1"><a href="#参数说明-1" class="headerlink" title="参数说明"></a>参数说明</h3><p>time 指定动画播放完成花费的时间。默认值为 0，意味着没有动画效果</p>
<h2 id="animation-timing-function-属性"><a href="#animation-timing-function-属性" class="headerlink" title="animation-timing-function 属性"></a>animation-timing-function 属性</h2><p><a target="_blank" rel="noopener" href="https://youchen12138.github.io/2019/08/19/CSS%E8%BF%9B%E9%98%B6%E7%9F%A5%E8%AF%86%E7%82%B9-%E8%BF%87%E6%B8%A1/">该属性请参考此链接</a></p>
<h2 id="animation-delay-属性"><a href="#animation-delay-属性" class="headerlink" title="animation-delay 属性"></a>animation-delay 属性</h2><p><a target="_blank" rel="noopener" href="https://youchen12138.github.io/2019/08/19/CSS%E8%BF%9B%E9%98%B6%E7%9F%A5%E8%AF%86%E7%82%B9-%E8%BF%87%E6%B8%A1/">该属性请参考此链接</a></p>
<h2 id="animation-iteration-count-属性"><a href="#animation-iteration-count-属性" class="headerlink" title="animation-iteration-count 属性"></a>animation-iteration-count 属性</h2><p>检索或设置对象动画的循环次数</p>
<h3 id="语法-2"><a href="#语法-2" class="headerlink" title="语法"></a>语法</h3><blockquote>
<p>animation-iteration-count: infinite | number</p>
</blockquote>
<h3 id="参数说明-2"><a href="#参数说明-2" class="headerlink" title="参数说明"></a>参数说明</h3><ul>
<li><p>number 为数字，其默认值为1</p>
</li>
<li><p>infinite 为无限次数循环</p>
</li>
</ul>
<h2 id="animation-direction-属性"><a href="#animation-direction-属性" class="headerlink" title="animation-direction 属性"></a>animation-direction 属性</h2><p>检索或设置对象动画在循环中是否反向运动</p>
<h3 id="语法-3"><a href="#语法-3" class="headerlink" title="语法"></a>语法</h3><blockquote>
<p>animation-direction: normal | reverse | alternate | alternate-reverse | initial | inherit</p>
</blockquote>
<h3 id="参数说明-3"><a href="#参数说明-3" class="headerlink" title="参数说明"></a>参数说明</h3><table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>normal</td>
<td>正常方向</td>
</tr>
<tr>
<td>reserve</td>
<td>反方向运行</td>
</tr>
<tr>
<td>alternate</td>
<td>动画先正常运行再反向运行，并持续交替运行</td>
</tr>
<tr>
<td>alternate-reserve</td>
<td>动画先反方向运行再正向运行，并持续交替运行</td>
</tr>
</tbody></table>
<h2 id="animation-fill-mode-属性"><a href="#animation-fill-mode-属性" class="headerlink" title="animation-fill-mode 属性"></a>animation-fill-mode 属性</h2><p>规定当动画不播放时（当动画完成或当动画有延迟未开始播放时），要应用到元素的样式</p>
<h3 id="语法-4"><a href="#语法-4" class="headerlink" title="语法"></a>语法</h3><blockquote>
<p>animation-fill-mode: none | forwords | backwards | both | initial | inherit</p>
</blockquote>
<h3 id="参数说明-4"><a href="#参数说明-4" class="headerlink" title="参数说明"></a>参数说明</h3><table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>none</td>
<td>默认值。不设置对象动画之外的状态</td>
</tr>
<tr>
<td>forwards</td>
<td>设置对象状态为动画结束时的状态</td>
</tr>
<tr>
<td>backwards</td>
<td>设置对象状态为动画开始时的状态</td>
</tr>
<tr>
<td>both</td>
<td>设置对象状态为动画结束或开始的状态</td>
</tr>
</tbody></table>
<h2 id="animation-play-state-属性"><a href="#animation-play-state-属性" class="headerlink" title="animation-play-state 属性"></a>animation-play-state 属性</h2><p>指定动画是否正在运行或已暂停</p>
<h3 id="语法-5"><a href="#语法-5" class="headerlink" title="语法"></a>语法</h3><p>animation-paly-state：paused | running</p>
<h3 id="参数说明-5"><a href="#参数说明-5" class="headerlink" title="参数说明"></a>参数说明</h3><ul>
<li><p>paused：暂停动画</p>
</li>
<li><p>running：默认值。正在运行的动画</p>
</li>
</ul>
<h1 id="animation-复合属性"><a href="#animation-复合属性" class="headerlink" title="animation 复合属性"></a>animation 复合属性</h1><p>检索或设置对象所应用的动画特效</p>
<h2 id="语法-6"><a href="#语法-6" class="headerlink" title="语法"></a>语法</h2><blockquote>
<p>animation: name duration timing-function delay iteration-count direction fill-mode play-state</p>
</blockquote>
<h1 id="keyframes"><a href="#keyframes" class="headerlink" title="@keyframes"></a>@keyframes</h1><h2 id="Keyframes-定义"><a href="#Keyframes-定义" class="headerlink" title="Keyframes 定义"></a>Keyframes 定义</h2><p>关键帧。可以指定任何顺序排列来决定 Animation 动画变化的关键位置</p>
<h2 id="使用说明"><a href="#使用说明" class="headerlink" title="使用说明"></a>使用说明</h2><p>使用 @keyframes 规则创建动画，通过逐步改变从一个 CSS 样式设定到另一个</p>
<p>在动画过程中可以通过 @keyframes 规则多次更改 CSS 样式的设定</p>
<h2 id="语法-7"><a href="#语法-7" class="headerlink" title="语法"></a>语法</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">@keyframes animationname&#123;</span><br><span class="line">    keyframes-selector&#123;</span><br><span class="line">      css-styles</span><br><span class="line">     &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="参数说明-6"><a href="#参数说明-6" class="headerlink" title="参数说明"></a>参数说明</h3><table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>animationname</td>
<td>必写项。定义 animation 的名称</td>
</tr>
<tr>
<td>keyframes-selector</td>
<td>必写项。动画持续时间的百分比，0~100%、from(0%)、to(100%)</td>
</tr>
<tr>
<td>css-styles</td>
<td>必写项。一个或多个合法的 CSS 样式属性</td>
</tr>
<tr>
<td>前缀</td>
<td>可选。如果需要，加在@后面 keyframes 前面</td>
</tr>
</tbody></table>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="https://youchen12138.gitee.io/hexo/2020/08/26/bootstrap%E5%85%A5%E9%97%A8%E4%B9%8B%E5%85%A8%E5%B1%80%E6%A0%B7%E5%BC%8F/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/hexo/images/avatar.jpg">
      <meta itemprop="name" content="幽辰">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="幽辰的博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/hexo/2020/08/26/bootstrap%E5%85%A5%E9%97%A8%E4%B9%8B%E5%85%A8%E5%B1%80%E6%A0%B7%E5%BC%8F/" class="post-title-link" itemprop="url">bootstrap入门之全局样式</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>
              

              <time title="Created: 2020-08-26 00:03:36 / Modified: 00:03:54" itemprop="dateCreated datePublished" datetime="2020-08-26T00:03:36+08:00">2020-08-26</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/hexo/categories/bootstrap/" itemprop="url" rel="index"><span itemprop="name">bootstrap</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="什么是-bootstrap"><a href="#什么是-bootstrap" class="headerlink" title="什么是 bootstrap"></a>什么是 bootstrap</h2><ul>
<li><p>bootstrap 是 Twitter 公司开发基于 HTML、CSS、JavaScript 的前端框架</p>
</li>
<li><p>为实现 web 应用程序快速开发提供的一套前端工具包</p>
</li>
<li><p>响应式布局</p>
</li>
<li><p>移动设备优先</p>
</li>
</ul>
<h2 id="bootstrap-的特性"><a href="#bootstrap-的特性" class="headerlink" title="bootstrap 的特性"></a>bootstrap 的特性</h2><ul>
<li><p>响应式设计</p>
</li>
<li><p>栅格布局</p>
</li>
<li><p>完整的类库</p>
</li>
<li><p>jQuery 插件</p>
</li>
</ul>
<h2 id="bootstrap-全局样式的特点"><a href="#bootstrap-全局样式的特点" class="headerlink" title="bootstrap 全局样式的特点"></a>bootstrap 全局样式的特点</h2><ul>
<li><p>代码整洁</p>
</li>
<li><p>风格统一</p>
</li>
<li><p>美观易用</p>
</li>
</ul>
<p>bootstrap 提供了大量的全局样式，基本的 HTML 元素均可以通过 class 设置样式并得到增强效果</p>
<h2 id="bootstrap-中的排版"><a href="#bootstrap-中的排版" class="headerlink" title="bootstrap 中的排版"></a>bootstrap 中的排版</h2><p>bootstrap 对默认的排版方式进行了 CSS 样式定义，使得各种基本结构套用出来的 HTML 页面更加美观</p>
<h3 id="标题"><a href="#标题" class="headerlink" title="标题"></a>标题</h3><ul>
<li><p>标题（h1 ~ h6 / .h1 ~ .h6）</p>
<table>
<thead>
<tr>
<th>标题</th>
<th>字体大小</th>
</tr>
</thead>
<tbody><tr>
<td>h1</td>
<td>36px</td>
</tr>
<tr>
<td>h2</td>
<td>30px</td>
</tr>
<tr>
<td>h3</td>
<td>24px</td>
</tr>
<tr>
<td>h4</td>
<td>18px</td>
</tr>
<tr>
<td>h5</td>
<td>14px</td>
</tr>
<tr>
<td>h6</td>
<td>12px</td>
</tr>
</tbody></table>
</li>
<li><p>副标题（small）</p>
</li>
</ul>
<h3 id="文本"><a href="#文本" class="headerlink" title="文本"></a>文本</h3><ul>
<li>段落</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">p 标签</span><br><span class="line"></span><br><span class="line">默认：14px</span><br><span class="line">行高：20px</span><br><span class="line">底部外边距：10px</span><br></pre></td></tr></table></figure>

<ul>
<li>强调</li>
</ul>
<blockquote>
<p><code>&lt;mark&gt;&lt;/mark&gt;</code></p>
</blockquote>
<ul>
<li>删除</li>
</ul>
<blockquote>
<p><code>&lt;del&gt;&lt;/del&gt;</code></p>
</blockquote>
<ul>
<li>下划线</li>
</ul>
<blockquote>
<p><code>&lt;ins&gt;&lt;/ins&gt;</code></p>
</blockquote>
<ul>
<li>文本标记</li>
</ul>
<h3 id="对齐"><a href="#对齐" class="headerlink" title="对齐"></a>对齐</h3><ul>
<li><p><code>.text-left</code></p>
</li>
<li><p><code>.text-center</code></p>
</li>
<li><p><code>.text-right</code></p>
</li>
</ul>
<h3 id="大小写"><a href="#大小写" class="headerlink" title="大小写"></a>大小写</h3><ul>
<li><p><code>.text-lowercase</code></p>
</li>
<li><p><code>.text-uppercase</code></p>
</li>
<li><p><code>.text-capitalize</code></p>
</li>
</ul>
<h2 id="表格"><a href="#表格" class="headerlink" title="表格"></a>表格</h2><ul>
<li><p>带边框的表格：<code>.table-bordered</code></p>
</li>
<li><p>条纹状表格：<code>.table-striped</code></p>
</li>
<li><p>悬停变色：<code>table-hover</code></p>
</li>
<li><p>紧凑风格：<code>.table-condensed</code></p>
</li>
</ul>
<h3 id="表格样式"><a href="#表格样式" class="headerlink" title="表格样式"></a>表格样式</h3><table>
<thead>
<tr>
<th>表格</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>.table-primary</code></td>
<td>蓝色: 指定这是一个重要的操作</td>
</tr>
<tr>
<td><code>.table-success</code></td>
<td>绿色: 指定这是一个允许执行的操作</td>
</tr>
<tr>
<td><code>.table-danger</code></td>
<td>红色: 指定这是可以危险的操作</td>
</tr>
<tr>
<td><code>.table-info</code></td>
<td>浅蓝色: 表示内容已变更</td>
</tr>
<tr>
<td><code>.table-warning</code></td>
<td>橘色: 表示需要注意的操作</td>
</tr>
<tr>
<td><code>.table-active</code></td>
<td>灰色: 用于鼠标悬停效果</td>
</tr>
<tr>
<td><code>.table-secondary</code></td>
<td>灰色: 表示内容不怎么重要</td>
</tr>
<tr>
<td><code>.table-light</code></td>
<td>浅灰色，可以是表格行的背景</td>
</tr>
<tr>
<td><code>.table-dark</code></td>
<td>深灰色，可以是表格行的背景</td>
</tr>
</tbody></table>
<h2 id="表单"><a href="#表单" class="headerlink" title="表单"></a>表单</h2><p>bootstrap 给 HTML 大部分表单都设置了默认样式，我们可以给表单添加相应类名，以实现表单的水平排列，个性化定制等</p>
<p>bootstrap 提供了下列类型的表单布局：</p>
<ul>
<li><p>垂直表单（默认）</p>
</li>
<li><p>内联表单</p>
</li>
<li><p>水平表单</p>
</li>
</ul>
<h3 id="基本表单（垂直表单）"><a href="#基本表单（垂直表单）" class="headerlink" title="基本表单（垂直表单）"></a>基本表单（垂直表单）</h3><p>创建基本表单的步骤：</p>
<ol>
<li><p>向父 <code>&lt;form&gt;</code> 元素添加 <code>role=&quot;form&quot;</code>。</p>
</li>
<li><p>把标签和控件放在一个带有 <code>class .form-group</code> 的 <code>&lt;div&gt;</code> 中。这是获取最佳间距所必需的。</p>
</li>
<li><p>向所有的文本元素 <code>&lt;input&gt;</code>、<code>&lt;textarea&gt;</code> 和 <code>&lt;select&gt;</code> 添加 <code>class =&quot;form-control&quot;</code> 。</p>
</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">&lt;form role&#x3D;&quot;form&quot;&gt;</span><br><span class="line">&lt;div class&#x3D;&quot;form-group&quot;&gt;</span><br><span class="line">    &lt;label for&#x3D;&quot;name&quot;&gt;名称&lt;&#x2F;label&gt;</span><br><span class="line">    &lt;input type&#x3D;&quot;text&quot; class&#x3D;&quot;form-control&quot; id&#x3D;&quot;name&quot; placeholder&#x3D;&quot;请输入名称&quot;&gt;</span><br><span class="line">&lt;&#x2F;div&gt;</span><br><span class="line">&lt;div class&#x3D;&quot;form-group&quot;&gt;</span><br><span class="line">    &lt;label for&#x3D;&quot;inputfile&quot;&gt;文件输入&lt;&#x2F;label&gt;</span><br><span class="line">    &lt;input type&#x3D;&quot;file&quot; id&#x3D;&quot;inputfile&quot;&gt;</span><br><span class="line">    &lt;p class&#x3D;&quot;help-block&quot;&gt;这里是块级帮助文本的实例。&lt;&#x2F;p&gt;</span><br><span class="line">&lt;&#x2F;div&gt;</span><br><span class="line">&lt;div class&#x3D;&quot;checkbox&quot;&gt;</span><br><span class="line">    &lt;label&gt;</span><br><span class="line">    &lt;input type&#x3D;&quot;checkbox&quot;&gt;请打勾</span><br><span class="line">    &lt;&#x2F;label&gt;</span><br><span class="line">&lt;&#x2F;div&gt;</span><br><span class="line">&lt;button type&#x3D;&quot;submit&quot; class&#x3D;&quot;btn btn-default&quot;&gt;提交&lt;&#x2F;button&gt;</span><br><span class="line">&lt;&#x2F;form&gt;</span><br></pre></td></tr></table></figure>

<h3 id="内联表单"><a href="#内联表单" class="headerlink" title="内联表单"></a>内联表单</h3><p>如果需要创建一个表单，它的所有元素是内联的，向左对齐的，标签是并排的，请向 <code>&lt;form&gt;</code> 标签添加 <code>class .form-inline</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">&lt;form class&#x3D;&quot;form-inline&quot; role&#x3D;&quot;form&quot;&gt;</span><br><span class="line">    &lt;div class&#x3D;&quot;form-group&quot;&gt;</span><br><span class="line">        &lt;label class&#x3D;&quot;sr-only&quot; for&#x3D;&quot;name&quot;&gt;名称&lt;&#x2F;label&gt;</span><br><span class="line">        &lt;input type&#x3D;&quot;text&quot; class&#x3D;&quot;form-control&quot; id&#x3D;&quot;name&quot; placeholder&#x3D;&quot;请输入名称&quot;&gt;</span><br><span class="line">    &lt;&#x2F;div&gt;</span><br><span class="line">    &lt;div class&#x3D;&quot;form-group&quot;&gt;</span><br><span class="line">        &lt;label class&#x3D;&quot;sr-only&quot; for&#x3D;&quot;inputfile&quot;&gt;文件输入&lt;&#x2F;label&gt;</span><br><span class="line">        &lt;input type&#x3D;&quot;file&quot; id&#x3D;&quot;inputfile&quot;&gt;</span><br><span class="line">    &lt;&#x2F;div&gt;</span><br><span class="line">    &lt;div class&#x3D;&quot;checkbox&quot;&gt;</span><br><span class="line">        &lt;label&gt;</span><br><span class="line">        &lt;input type&#x3D;&quot;checkbox&quot;&gt;请打勾</span><br><span class="line">        &lt;&#x2F;label&gt;</span><br><span class="line">    &lt;&#x2F;div&gt;</span><br><span class="line">    &lt;button type&#x3D;&quot;submit&quot; class&#x3D;&quot;btn btn-default&quot;&gt;提交&lt;&#x2F;button&gt;</span><br><span class="line">&lt;&#x2F;form&gt;</span><br></pre></td></tr></table></figure>

<h4 id="注意"><a href="#注意" class="headerlink" title="注意"></a>注意</h4><ul>
<li><p>默认情况下，Bootstrap 中的 <code>input``、select</code> 和 <code>textarea</code> 有 100% 宽度。在使用内联表单时，您需要在表单控件上设置一个宽度。</p>
</li>
<li><p>使用 <code>class .sr-only</code>，您可以隐藏内联表单的标签。</p>
</li>
</ul>
<h3 id="水平表单"><a href="#水平表单" class="headerlink" title="水平表单"></a>水平表单</h3><p>水平表单与其他表单不仅标记的数量上不同，而且表单的呈现形式也不同。如需创建一个水平布局的表单，请按下面的几个步骤进行：</p>
<ol>
<li><p>向父 <code>&lt;form&gt;</code> 元素添加 <code>class .form-horizontal</code></p>
</li>
<li><p>把标签和控件放在一个带有 <code>class .form-group</code> 的 <code>&lt;div&gt;</code> 中</p>
</li>
<li><p>向标签添加 <code>class .control-label</code></p>
</li>
</ol>
<p>实例</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">&lt;form class&#x3D;&quot;form-horizontal&quot; role&#x3D;&quot;form&quot;&gt;</span><br><span class="line">    &lt;div class&#x3D;&quot;form-group&quot;&gt;</span><br><span class="line">        &lt;label for&#x3D;&quot;firstname&quot; class&#x3D;&quot;col-sm-2 control-label&quot;&gt;名字&lt;&#x2F;label&gt;</span><br><span class="line">        &lt;div class&#x3D;&quot;col-sm-10&quot;&gt;</span><br><span class="line">        &lt;input type&#x3D;&quot;text&quot; class&#x3D;&quot;form-control&quot; id&#x3D;&quot;firstname&quot; placeholder&#x3D;&quot;请输入名字&quot;&gt;</span><br><span class="line">        &lt;&#x2F;div&gt;</span><br><span class="line">    &lt;&#x2F;div&gt;</span><br><span class="line">    &lt;div class&#x3D;&quot;form-group&quot;&gt;</span><br><span class="line">        &lt;label for&#x3D;&quot;lastname&quot; class&#x3D;&quot;col-sm-2 control-label&quot;&gt;姓&lt;&#x2F;label&gt;</span><br><span class="line">        &lt;div class&#x3D;&quot;col-sm-10&quot;&gt;</span><br><span class="line">        &lt;input type&#x3D;&quot;text&quot; class&#x3D;&quot;form-control&quot; id&#x3D;&quot;lastname&quot; placeholder&#x3D;&quot;请输入姓&quot;&gt;</span><br><span class="line">        &lt;&#x2F;div&gt;</span><br><span class="line">    &lt;&#x2F;div&gt;</span><br><span class="line">    &lt;div class&#x3D;&quot;form-group&quot;&gt;</span><br><span class="line">        &lt;div class&#x3D;&quot;col-sm-offset-2 col-sm-10&quot;&gt;</span><br><span class="line">        &lt;div class&#x3D;&quot;checkbox&quot;&gt;</span><br><span class="line">            &lt;label&gt;</span><br><span class="line">            &lt;input type&#x3D;&quot;checkbox&quot;&gt;请记住我</span><br><span class="line">            &lt;&#x2F;label&gt;</span><br><span class="line">        &lt;&#x2F;div&gt;</span><br><span class="line">        &lt;&#x2F;div&gt;</span><br><span class="line">    &lt;&#x2F;div&gt;</span><br><span class="line">    &lt;div class&#x3D;&quot;form-group&quot;&gt;</span><br><span class="line">        &lt;div class&#x3D;&quot;col-sm-offset-2 col-sm-10&quot;&gt;</span><br><span class="line">        &lt;button type&#x3D;&quot;submit&quot; class&#x3D;&quot;btn btn-default&quot;&gt;登录&lt;&#x2F;button&gt;</span><br><span class="line">        &lt;&#x2F;div&gt;</span><br><span class="line">    &lt;&#x2F;div&gt;</span><br><span class="line">&lt;&#x2F;form&gt;</span><br></pre></td></tr></table></figure>

<h3 id="输入框"><a href="#输入框" class="headerlink" title="输入框"></a>输入框</h3><p>向 <code>input</code> 输入框添加以下类名可产生相应变化</p>
<table>
<thead>
<tr>
<th>类名</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>.input-lg</code></td>
<td>输入框变大</td>
</tr>
<tr>
<td><code>.input-sm</code></td>
<td>输入框变小</td>
</tr>
</tbody></table>
<h3 id="标签"><a href="#标签" class="headerlink" title="标签"></a>标签</h3><p>向 <code>label</code> 标签添加以下类名可产生相应变化</p>
<table>
<thead>
<tr>
<th>类名</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>.sr-only</code></td>
<td>该标签隐藏</td>
</tr>
<tr>
<td><code>.control-label</code></td>
<td>如果上一级包含<code>.form-group</code>的<code>div</code>标签中有类似于<code>.has-success</code>的类名，改变该标签的状态</td>
</tr>
</tbody></table>
<h3 id="按钮"><a href="#按钮" class="headerlink" title="按钮"></a>按钮</h3><p>向 <code>button</code> 标签添加以下类名可产生相应变化</p>
<p>并不局限于 <code>button</code> 标签，比如也可以在 <code>a</code> 标签中设置</p>
<table>
<thead>
<tr>
<th>类名</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>.btn</code></td>
<td>按钮变为圆角</td>
</tr>
<tr>
<td><code>.btn-default</code></td>
<td>鼠标移入、访问会有不同效果</td>
</tr>
<tr>
<td><code>.btn-success</code></td>
<td>改变颜色。绿色</td>
</tr>
<tr>
<td><code>.btn-lg</code></td>
<td>按钮变大</td>
</tr>
<tr>
<td><code>.btn-sm</code></td>
<td>按钮变小</td>
</tr>
<tr>
<td><code>.btn-block</code></td>
<td>按钮长度和屏幕一样长</td>
</tr>
</tbody></table>
<h2 id="图片"><a href="#图片" class="headerlink" title="图片"></a>图片</h2><table>
<thead>
<tr>
<th>类名</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>.img-rounded</code></td>
<td>圆角</td>
</tr>
<tr>
<td><code>.img-circle</code></td>
<td>圆形</td>
</tr>
<tr>
<td><code>.img-thumbnail</code></td>
<td>带有边框的圆角图形</td>
</tr>
<tr>
<td><code>.img-responsive</code></td>
<td>图片响应式 (将很好地扩展到父元素)</td>
</tr>
</tbody></table>
<h2 id="辅助类"><a href="#辅助类" class="headerlink" title="辅助类"></a>辅助类</h2><p><a target="_blank" rel="noopener" href="https://www.runoob.com/bootstrap/bootstrap-helper-classes.html">请转至此链接查看</a></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="https://youchen12138.gitee.io/hexo/2020/08/26/bootstrap%E7%BB%84%E4%BB%B6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/hexo/images/avatar.jpg">
      <meta itemprop="name" content="幽辰">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="幽辰的博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/hexo/2020/08/26/bootstrap%E7%BB%84%E4%BB%B6/" class="post-title-link" itemprop="url">bootstrap组件</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>
              

              <time title="Created: 2020-08-26 00:02:29 / Modified: 00:02:58" itemprop="dateCreated datePublished" datetime="2020-08-26T00:02:29+08:00">2020-08-26</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/hexo/categories/bootstrap/" itemprop="url" rel="index"><span itemprop="name">bootstrap</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="响应式页面开发"><a href="#响应式页面开发" class="headerlink" title="响应式页面开发"></a>响应式页面开发</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">@media screen and (min-width: *px) and (max-width)&#123;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="栅格布局"><a href="#栅格布局" class="headerlink" title="栅格布局"></a>栅格布局</h2><p>将屏幕分成12格</p>
<ul>
<li><p>元素所占屏幕大小：<code>col-屏幕型号-num</code></p>
</li>
<li><p>元素距左侧几格：<code>col-屏幕型号-offset-num</code></p>
</li>
</ul>
<h2 id="网页开发中的单位"><a href="#网页开发中的单位" class="headerlink" title="网页开发中的单位"></a>网页开发中的单位</h2><p>px：相对于屏幕分辨率的长度单位</p>
<p>em：相对于当前文本内的字体尺寸</p>
<p>rem 与 em 相似，相对于 HTML 根节点的字体单位</p>
<h3 id="px"><a href="#px" class="headerlink" title="px"></a>px</h3><p>px 是相对于屏幕分辨率的单位</p>
<p>px 的大小无法跟随屏幕放大缩小</p>
<h3 id="em"><a href="#em" class="headerlink" title="em"></a>em</h3><p>1em = 16px（但不完全是）</p>
<p>em 会继承父级元素的字体大小，适合手机端、平板开发</p>
<p>IE 的部分版本不支持 em</p>
<h3 id="rem"><a href="#rem" class="headerlink" title="rem"></a>rem</h3><p>rem 与 em 类似</p>
<p>rem 会继承根元素的字体大小</p>
<h2 id="bootstrap-组件"><a href="#bootstrap-组件" class="headerlink" title="bootstrap 组件"></a>bootstrap 组件</h2><ol>
<li><p>role：标识普通标签，使之语义化，方便浏览器对其具体的功能进行识别</p>
</li>
<li><p>aria-label：当焦点落到输入框时，读屏软件就会读出输入框内容</p>
</li>
<li><p>tabIndex：可以设置键盘上的 tab 键在控件中进行移动</p>
</li>
<li><p>通过该自定义属性管理交互、效果</p>
</li>
</ol>
<h3 id="字体图标"><a href="#字体图标" class="headerlink" title="字体图标"></a>字体图标</h3><ol>
<li><p>glyphicon</p>
</li>
<li><p>glyphicon-具体图标</p>
</li>
</ol>
<h3 id="下拉菜单"><a href="#下拉菜单" class="headerlink" title="下拉菜单"></a>下拉菜单</h3><ol>
<li><p>.dropdown 控制组件为下拉</p>
</li>
<li><p>.dropdown-menu-right 代替 .pull-right 右对齐</p>
</li>
<li><p>.divider 分割线</p>
</li>
</ol>
<h3 id="控件组"><a href="#控件组" class="headerlink" title="控件组"></a>控件组</h3><ol>
<li><p>.input-group 表示控件组</p>
</li>
<li><p>.input-group-addon 可放置额外内容和图标</p>
</li>
</ol>
<h3 id="导航"><a href="#导航" class="headerlink" title="导航"></a>导航</h3><ol>
<li><p>以一个带有 class .nav 的无序列表开始</p>
</li>
<li><p>.nav-tabs 代表可切换的导航</p>
</li>
<li><p>.nav-pills 代表胶囊导航</p>
</li>
<li><p>.nav-justified 使导航垂直</p>
</li>
</ol>
<h3 id="分页"><a href="#分页" class="headerlink" title="分页"></a>分页</h3><ol>
<li><p>.pagination 在父元素中添加表示分页</p>
</li>
<li><p>.pager 放置在翻页区域</p>
</li>
<li><p>.previous 把链接向左对齐，.next 把链接向右对齐</p>
</li>
</ol>
<h3 id="进度条"><a href="#进度条" class="headerlink" title="进度条"></a>进度条</h3><ol>
<li><p>.progress 表示进度条</p>
</li>
<li><p>通过状态类改变进度条的颜色</p>
</li>
<li><p>.progress-bar-striped 使得进度条颜色渐变</p>
</li>
</ol>
<h3 id="列表"><a href="#列表" class="headerlink" title="列表"></a>列表</h3><ol>
<li><p>.list-group 代表列表组</p>
</li>
<li><p>.badge 代表状态数</p>
</li>
<li><p>.active 代表选中状态</p>
</li>
</ol>
<h3 id="面板"><a href="#面板" class="headerlink" title="面板"></a>面板</h3><ol>
<li><p>.panel 代表面板</p>
</li>
<li><p>.panel-body 代表面板内容</p>
</li>
<li><p>.panel-footer 代表面板的注脚</p>
</li>
</ol>
<h2 id="Bootstrap-中的插件"><a href="#Bootstrap-中的插件" class="headerlink" title="Bootstrap 中的插件"></a>Bootstrap 中的插件</h2><ol>
<li><p>Bootstrap 插件依赖 Bootstrap.js</p>
</li>
<li><p>Bootstrap.js 基于 JQuery</p>
</li>
</ol>
<h3 id="data-属性"><a href="#data-属性" class="headerlink" title="data 属性"></a>data 属性</h3><ol>
<li><p>通过 data 属性控制页面交互</p>
</li>
<li><p>$(document).off(‘.data-api’) 解除属性绑定</p>
</li>
</ol>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="https://youchen12138.gitee.io/hexo/2020/08/25/egg-ts%E4%BD%BF%E7%94%A8sequelize/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/hexo/images/avatar.jpg">
      <meta itemprop="name" content="幽辰">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="幽辰的博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/hexo/2020/08/25/egg-ts%E4%BD%BF%E7%94%A8sequelize/" class="post-title-link" itemprop="url">egg+ts使用sequelize</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2020-08-25 23:57:52" itemprop="dateCreated datePublished" datetime="2020-08-25T23:57:52+08:00">2020-08-25</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2020-08-26 00:01:45" itemprop="dateModified" datetime="2020-08-26T00:01:45+08:00">2020-08-26</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/hexo/categories/egg/" itemprop="url" rel="index"><span itemprop="name">egg</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p><strong>安装</strong></p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -<span class="literal">-save</span> egg<span class="literal">-sequelize</span> mysql2</span><br></pre></td></tr></table></figure>

<p><strong>配置</strong></p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// config/plugin.ts</span></span><br><span class="line">sequelize: &#123;</span><br><span class="line">  enable: <span class="literal">true</span>,</span><br><span class="line">  package: <span class="string">&#x27;egg-sequelize&#x27;</span>,</span><br><span class="line">&#125;,</span><br><span class="line">    </span><br><span class="line"><span class="comment">// config/config.defaullt.ts</span></span><br><span class="line">config.sequelize = &#123;</span><br><span class="line">  dialect: <span class="string">&#x27;mysql&#x27;</span>, <span class="comment">// 表示是mysql数据库</span></span><br><span class="line">  host: <span class="string">&#x27;127.0.0.1&#x27;</span>,</span><br><span class="line">  port: <span class="number">3306</span>,</span><br><span class="line">  database: <span class="string">&#x27;test&#x27;</span>,</span><br><span class="line">  username: <span class="string">&#x27;root&#x27;</span>,</span><br><span class="line">  password: <span class="string">&#x27;123456&#x27;</span>,</span><br><span class="line">  timezone: <span class="string">&#x27;+08:00&#x27;</span>, <span class="comment">// 表示为东八区的时间</span></span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<p><strong>model 创建</strong></p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// app/model/User.ts</span></span><br><span class="line"><span class="keyword">import</span> &#123; Application &#125; <span class="keyword">from</span> <span class="string">&#x27;egg&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> <span class="function"><span class="keyword">function</span>(<span class="params">app: Application</span>) </span>&#123;</span><br><span class="line">  <span class="keyword">const</span> &#123; STRING, INTEGER, BIGINT &#125; = app.Sequelize;</span><br><span class="line">  <span class="keyword">const</span> User = app.model.define(<span class="string">&#x27;users&#x27;</span>, &#123;</span><br><span class="line">    id: &#123;</span><br><span class="line">      <span class="keyword">type</span>: INTEGER, <span class="comment">// INTEGER就是mysql中的int</span></span><br><span class="line">      primaryKey: <span class="literal">true</span>,</span><br><span class="line">      autoIncrement: <span class="literal">true</span>, <span class="comment">// 自动增长</span></span><br><span class="line">    &#125;,</span><br><span class="line">    app_name: STRING(<span class="number">20</span>),</span><br><span class="line">    j: BIGINT,</span><br><span class="line">    url: STRING(<span class="number">100</span>),</span><br><span class="line">    country: STRING(<span class="number">10</span>),</span><br><span class="line">  &#125;, &#123;</span><br><span class="line">    <span class="comment">// timestamps: false, // 去除createAt updateAt</span></span><br><span class="line">    createdAt: <span class="literal">false</span>, <span class="comment">// 表示不启用created_at</span></span><br><span class="line">    updatedAt: <span class="literal">false</span>, <span class="comment">// 表示不启用updated_at</span></span><br><span class="line">    freezeTableName: <span class="literal">true</span>, <span class="comment">// 使用自定义表名</span></span><br><span class="line">    <span class="comment">// 使用自定义表名之后上面写的users就直接就是你的表名，如果不加的话，你就可以写user，但是自己的表名为users，程序会自动将s加上</span></span><br><span class="line">    tableName: <span class="string">&#x27;users&#x27;</span>, <span class="comment">// 自定义的表名，也可以不写，直接用define后面的也可以</span></span><br><span class="line">    <span class="comment">// 只要你使用了freezeTableName，程序就不会自动给你加上s了</span></span><br><span class="line">  &#125;);</span><br><span class="line"></span><br><span class="line">  <span class="keyword">return</span> <span class="keyword">class</span> <span class="keyword">extends</span> User &#123;&#125;;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="命令"><a href="#命令" class="headerlink" title="命令"></a>命令</h2><h3 id="增加数据"><a href="#增加数据" class="headerlink" title="增加数据"></a>增加数据</h3><figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> res = <span class="keyword">await</span> ctx.model.User.create(&#123;</span><br><span class="line">    app_name: <span class="string">&#x27;xxx&#x27;</span>,</span><br><span class="line">    j: <span class="number">10</span>,</span><br><span class="line">    url: <span class="string">&#x27;http://xxx.com&#x27;</span>,</span><br><span class="line">    country: <span class="string">&#x27;CN&#x27;</span>,</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<h3 id="查找"><a href="#查找" class="headerlink" title="查找"></a>查找</h3><p><strong>查找表中全部数据</strong></p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> res = <span class="keyword">await</span> ctx.model.User.findAll();</span><br></pre></td></tr></table></figure>

<p><strong>投影表中部分字段</strong></p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> res = <span class="keyword">await</span> ctx.model.User.findAll(&#123;</span><br><span class="line">    attributes: [ <span class="string">&#x27;id&#x27;</span>, <span class="string">&#x27;app_name&#x27;</span> ], <span class="comment">// 投影id和app_name</span></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<p><strong>条件查询</strong></p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> res = <span class="keyword">await</span> ctx.model.User.findAll(&#123;</span><br><span class="line">    attributes: [ <span class="string">&#x27;id&#x27;</span>, <span class="string">&#x27;app_name&#x27;</span> ],</span><br><span class="line">    where: &#123;</span><br><span class="line">      id: <span class="number">2</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    limit: <span class="number">1</span>, <span class="comment">// 限制</span></span><br><span class="line">    offset: <span class="number">1</span>, <span class="comment">// 偏移</span></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<p><strong>根据主键查找</strong></p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> res = <span class="keyword">await</span> ctx.model.User.findByPk(<span class="number">1</span>);</span><br></pre></td></tr></table></figure>

<h3 id="修改数据"><a href="#修改数据" class="headerlink" title="修改数据"></a>修改数据</h3><figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> res = <span class="keyword">await</span> ctx.model.User.findByPk(<span class="number">22</span>);</span><br><span class="line">res?.update(&#123; app_name: <span class="string">&#x27;xxx&#x27;</span> &#125;);</span><br></pre></td></tr></table></figure>

<p>查找到相应元组再更新数据</p>
<h3 id="删除数据"><a href="#删除数据" class="headerlink" title="删除数据"></a>删除数据</h3><figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> res = <span class="keyword">await</span> ctx.model.User.findByPk(<span class="number">22</span>);</span><br><span class="line">res?.destroy();</span><br></pre></td></tr></table></figure>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="https://youchen12138.gitee.io/hexo/2019/05/25/%E8%B7%A8%E5%9F%9F/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/hexo/images/avatar.jpg">
      <meta itemprop="name" content="幽辰">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="幽辰的博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/hexo/2019/05/25/%E8%B7%A8%E5%9F%9F/" class="post-title-link" itemprop="url">跨域</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2019-05-25 14:59:34" itemprop="dateCreated datePublished" datetime="2019-05-25T14:59:34+08:00">2019-05-25</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2020-08-30 19:31:34" itemprop="dateModified" datetime="2020-08-30T19:31:34+08:00">2020-08-30</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/hexo/categories/%E5%85%B6%E4%BB%96/" itemprop="url" rel="index"><span itemprop="name">其他</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <ul>
<li>一个域名地址的组成</li>
</ul>
<table>
<thead>
<tr>
<th>http://</th>
<th>www.</th>
<th>abc.com</th>
<th>8080/</th>
<th>script/jquery.js</th>
</tr>
</thead>
<tbody><tr>
<td>协议</td>
<td>子域名</td>
<td>主域名</td>
<td>端口号</td>
<td>请求资源地址</td>
</tr>
</tbody></table>
<ul>
<li><p>当协议、子域名、主域名、端口号中任意一个不相同时，都算作不同域</p>
</li>
<li><p>不同域之间相互请求资源，就算作“跨域”</p>
</li>
</ul>
<p>比如：<a target="_blank" rel="noopener" href="http://www.abc.com/index.html">http://www.abc.com/index.html</a> 请求 <a target="_blank" rel="noopener" href="http://www.efg.com/service.php">http://www.efg.com/service.php</a></p>
<ul>
<li>JavaScript处于安全方面的考虑，不允许跨域调用其它页面的对象。什么是跨域呢，简单的理解就是JavaScript同源策略的限制，<code>a.com</code>域名下的js无法操作<code>b.com</code>或是<code>c.a.com</code>域名下的对象</li>
</ul>
<h2 id="处理跨域方法一——代理"><a href="#处理跨域方法一——代理" class="headerlink" title="处理跨域方法一——代理"></a>处理跨域方法一——代理</h2><ul>
<li><p>通过在同域名的web服务器创建一个代理：</p>
</li>
<li><p>北京服务器（域名：<a target="_blank" rel="noopener" href="http://www.beijing.com)/">www.beijing.com）</a></p>
<p>  上海服务器（域名：<a target="_blank" rel="noopener" href="http://www.shanghai.com)/">www.shanghai.com）</a></p>
</li>
</ul>
<ul>
<li><p>比如在北京的web服务器的后台</p>
<p>  <code>(www.beijing.com/proxy-shanghaiservice.php)</code>来调用上海服务器<code>(www.shanghai.com/service.php)</code>的服务，然后再把响应结果返回给前端，这样前端调用北京同域名的服务就和调用上海的服务效果相同了</p>
</li>
</ul>
<h2 id="处理跨域方法二——JSONP"><a href="#处理跨域方法二——JSONP" class="headerlink" title="处理跨域方法二——JSONP"></a>处理跨域方法二——JSONP</h2><ul>
<li><p>JSONP可用于解决主流浏览器的跨域数据访问的问题（通过script标签来调用其它页面）</p>
</li>
<li><p>JSONP不支持POST请求</p>
</li>
</ul>
<h2 id="处理跨域方法三——XHR2"><a href="#处理跨域方法三——XHR2" class="headerlink" title="处理跨域方法三——XHR2"></a>处理跨域方法三——XHR2</h2><ul>
<li><p>HTML5提供的XMLHttpRequest Level2已经实现了跨域访问以及其他的一些新功能</p>
</li>
<li><p>IE10以下的版本都不支持</p>
</li>
<li><p>在服务器端做一些小小的改造即可：</p>
<p>  <code>header(&#39;Access-Control-Allow-Origin: *&#39;);</code></p>
<p>  <code>header(&#39;Access-Control-Allow-Methods:POST,GET&#39;);</code></p>
</li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="https://youchen12138.gitee.io/hexo/2019/05/25/%E7%94%A8jQuery%E5%AE%9E%E7%8E%B0Ajax-md/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/hexo/images/avatar.jpg">
      <meta itemprop="name" content="幽辰">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="幽辰的博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/hexo/2019/05/25/%E7%94%A8jQuery%E5%AE%9E%E7%8E%B0Ajax-md/" class="post-title-link" itemprop="url">用jQuery实现Ajax</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>
              

              <time title="Created: 2019-05-25 14:39:57 / Modified: 14:59:08" itemprop="dateCreated datePublished" datetime="2019-05-25T14:39:57+08:00">2019-05-25</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/hexo/categories/Ajax/" itemprop="url" rel="index"><span itemprop="name">Ajax</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="jQuery提供的Ajax方法"><a href="#jQuery提供的Ajax方法" class="headerlink" title="jQuery提供的Ajax方法"></a>jQuery提供的Ajax方法</h2><ul>
<li><p>type：类型，“POST”或“GET”，默认为“GET”</p>
</li>
<li><p>url：发送请求的地址</p>
</li>
<li><p>data：是一个对象，连同请求发送到服务器的数据</p>
</li>
<li><p>dataType：预期服务器返回的数据类型。如果不指定，jQuery将自动根据HTTP包MIME信息来智能判断，一<br>般我们采用json格式，可以设置为“json”</p>
</li>
<li><p>success：是一个方法，请求成功后的回调函数。传入返回后的数据，以及包含成功代码的字符串</p>
</li>
<li><p>error：是一个方法，请求失败时调用此函数。传入XMLHttpRequest对象</p>
</li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="https://youchen12138.gitee.io/hexo/2019/05/17/JSON%E6%A0%BC%E5%BC%8F-md/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/hexo/images/avatar.jpg">
      <meta itemprop="name" content="幽辰">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="幽辰的博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/hexo/2019/05/17/JSON%E6%A0%BC%E5%BC%8F-md/" class="post-title-link" itemprop="url">JSON格式</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2019-05-17 12:58:44" itemprop="dateCreated datePublished" datetime="2019-05-17T12:58:44+08:00">2019-05-17</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2019-05-26 10:47:10" itemprop="dateModified" datetime="2019-05-26T10:47:10+08:00">2019-05-26</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/hexo/categories/JSON/" itemprop="url" rel="index"><span itemprop="name">JSON</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="JSON基本概念"><a href="#JSON基本概念" class="headerlink" title="JSON基本概念"></a>JSON基本概念</h2><ul>
<li><p>JSON：JavaScript对象表示法（JavaScript object Notation）</p>
</li>
<li><p>JSON是存储和交换文本信息的语法，类似XML。它采用键值对的方式来组织，易于人们阅读和编写，同时也易于机器解析和生成</p>
</li>
<li><p>JSON是独立于语言的，也就是说不管什么语言，都可以解析JSON，只需要按照JSON的规则就行</p>
</li>
</ul>
<h3 id="JSON与XML比较"><a href="#JSON与XML比较" class="headerlink" title="JSON与XML比较"></a>JSON与XML比较</h3><ul>
<li><p>JSON的长度和XML格式比起来很短小，在网络传输的过程中可以大大减少带宽</p>
</li>
<li><p>JSON读写的速度更快</p>
</li>
<li><p>JSON可以使用JavaScript内建的方法直接进行解析，转换成JavaScript对象，非常方便</p>
</li>
</ul>
<h3 id="JSON语法规则"><a href="#JSON语法规则" class="headerlink" title="JSON语法规则"></a>JSON语法规则</h3><ul>
<li><p>JSON数据的书写格式是：名称/值对</p>
<p>  名称/值对组合中的名称写在前面（在双引号中），值对写在后面（同样写在双引号中），中间用冒号隔开：比如”name”:”郭靖”</p>
</li>
<li><p>JSON的值可以是下面这些类型：</p>
<p>  数字（整数或浮点数），比如123, 1.23</p>
<p>  字符串（在双引号中）</p>
<p>  逻辑值（布尔值 true或false）</p>
<p>  数组（在方括号中）</p>
<p>  对象（在花括号中）</p>
<p>  null</p>
</li>
</ul>
<h3 id="JSON约定"><a href="#JSON约定" class="headerlink" title="JSON约定"></a>JSON约定</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    &quot;success&quot;:true,                     &#x2F;&#x2F;表示是否正确执行了，请求是否成功</span><br><span class="line">    &quot;msg&quot;:&quot;xxx&quot;,                        &#x2F;&#x2F;这个请求为false时返回的信息</span><br><span class="line">    &quot;data&quot;:&quot;xxx&quot;                        &#x2F;&#x2F;这个请求的返回值</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    &quot;success&quot;:true,                     &#x2F;&#x2F;表示是否正确执行了，请求是否成功</span><br><span class="line">    &quot;msg&quot;:&quot;xxx&quot;,  </span><br><span class="line">&#125;                      &#x2F;&#x2F;返回的信息</span><br></pre></td></tr></table></figure>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="https://youchen12138.gitee.io/hexo/2019/05/16/XMLHttpRequest-md/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/hexo/images/avatar.jpg">
      <meta itemprop="name" content="幽辰">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="幽辰的博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/hexo/2019/05/16/XMLHttpRequest-md/" class="post-title-link" itemprop="url">XMLHttpRequest</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>
              

              <time title="Created: 2019-05-16 17:16:17 / Modified: 17:56:42" itemprop="dateCreated datePublished" datetime="2019-05-16T17:16:17+08:00">2019-05-16</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/hexo/categories/Ajax/" itemprop="url" rel="index"><span itemprop="name">Ajax</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="XMLHTTPRequest发送请求"><a href="#XMLHTTPRequest发送请求" class="headerlink" title="XMLHTTPRequest发送请求"></a>XMLHTTPRequest发送请求</h2><h3 id="方法"><a href="#方法" class="headerlink" title="方法"></a>方法</h3><blockquote>
<p>将请求发送到服务器上</p>
</blockquote>
<ul>
<li><p>open(method, url, async)</p>
<p>  method：采用了什么方式（GET还是POST）</p>
<p>  url：请求的地址。可以使用相对地址也可以使用绝对地址</p>
<p>  async请求同步/异步。true表示异步，flase表示同步</p>
</li>
<li><p>send(string)</p>
<p>  使用GET可以不填写string参数，使用POST必须填写string参数</p>
</li>
</ul>
<h3 id="取得响应"><a href="#取得响应" class="headerlink" title="取得响应"></a>取得响应</h3><ul>
<li><p>responseText：获得字符串形式的响应数据</p>
</li>
<li><p>responseXML：获得XML形式的响应数据</p>
</li>
<li><p>status和statusText：以数字和文本形式返回HTTP状态码</p>
</li>
<li><p>getAllResponseHeader()：获取所有的响应报头</p>
</li>
<li><p>getResponseHeader()：查询响应中的某个字段的值</p>
</li>
</ul>
<h3 id="readyState属性"><a href="#readyState属性" class="headerlink" title="readyState属性"></a>readyState属性</h3><blockquote>
<p>0：请求未初始化，open还没有调用</p>
</blockquote>
<blockquote>
<p>1：服务器连接已建立，open已经调用了</p>
</blockquote>
<blockquote>
<p>2：请求已接收，也就是接收到头信息了</p>
</blockquote>
<blockquote>
<p>3：请求处理中，也就是接收到响应主体了</p>
</blockquote>
<blockquote>
<p>4：请求已完成，且响应已就绪，也就是响应完成了</p>
</blockquote>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="https://youchen12138.gitee.io/hexo/2019/05/16/HTTP%E8%AF%B7%E6%B1%82/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/hexo/images/avatar.jpg">
      <meta itemprop="name" content="幽辰">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="幽辰的博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/hexo/2019/05/16/HTTP%E8%AF%B7%E6%B1%82/" class="post-title-link" itemprop="url">HTTP请求</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>
              

              <time title="Created: 2019-05-16 15:28:06 / Modified: 17:58:38" itemprop="dateCreated datePublished" datetime="2019-05-16T15:28:06+08:00">2019-05-16</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/hexo/categories/Ajax/" itemprop="url" rel="index"><span itemprop="name">Ajax</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="什么是HTTP"><a href="#什么是HTTP" class="headerlink" title="什么是HTTP"></a>什么是HTTP</h2><ul>
<li><p>http是计算机通过网络进行通信的规则。</p>
</li>
<li><p>主要使浏览器能够从web服务器去请求信息和服务。</p>
</li>
<li><p>HTTP是一种无状态的协议。无状态指的是不建立持久的连接，服务端不保留连接的一些相关信息。</p>
</li>
</ul>
<h2 id="概念介绍——HTTP请求"><a href="#概念介绍——HTTP请求" class="headerlink" title="概念介绍——HTTP请求"></a>概念介绍——HTTP请求</h2><h3 id="HTTP请求通常有以下7个步骤"><a href="#HTTP请求通常有以下7个步骤" class="headerlink" title="HTTP请求通常有以下7个步骤"></a>HTTP请求通常有以下7个步骤</h3><ol>
<li><p>建立TCP连接</p>
</li>
<li><p>Web浏览器向Web服务器发送请求命令</p>
</li>
<li><p>Web浏览器发送请求头信息</p>
</li>
<li><p>Web服务器应答</p>
</li>
<li><p>Web服务器发送应答头信息</p>
</li>
<li><p>Web服务器向浏览器发送数据</p>
</li>
<li><p>Web服务器关闭TCP连接</p>
</li>
</ol>
<h3 id="HTTP请求一般由四部分组成"><a href="#HTTP请求一般由四部分组成" class="headerlink" title="HTTP请求一般由四部分组成"></a>HTTP请求一般由四部分组成</h3><ol>
<li><p>HTTP请求的方法或动作，比如是GET还是POST请求</p>
</li>
<li><p>正在请求的URL，总得知道请求的地址是什么吧</p>
</li>
<li><p>请求头，包含一些客户端环境信息，身份验证信息等</p>
</li>
<li><p>请求体，也就是请求正文，请求正文中可以包含客户提交的查询字符串信息，表单信息等等</p>
</li>
</ol>
<h3 id="两种请求区别"><a href="#两种请求区别" class="headerlink" title="两种请求区别"></a>两种请求区别</h3><ul>
<li><p>GET： </p>
<ol>
<li><p>一般用于信息获取</p>
</li>
<li><p>使用URL传递参数</p>
</li>
<li><p>对所发送信息的数量也有限制，一般在2000个字符</p>
</li>
</ol>
</li>
<li><p>POST</p>
<ol>
<li><p>一般用于修改服务器上的资源</p>
</li>
<li><p>对所发送信息的数量无限制</p>
</li>
</ol>
</li>
</ul>
<h2 id="HTTP响应"><a href="#HTTP响应" class="headerlink" title="HTTP响应"></a>HTTP响应</h2><h3 id="一个HTTP响应一般由三部分组成"><a href="#一个HTTP响应一般由三部分组成" class="headerlink" title="一个HTTP响应一般由三部分组成"></a>一个HTTP响应一般由三部分组成</h3><ol>
<li><p>一个数字和文字组成的状态码，用来显示请求成功还是失败</p>
</li>
<li><p>响应头，响应头也和请求头一样包含许多有用的信息，例如服务器类型、日期时间、内容类型和长度等</p>
</li>
<li><p>响应体，也就是响应正文</p>
</li>
</ol>
<h3 id="HTTP状态码（status）"><a href="#HTTP状态码（status）" class="headerlink" title="HTTP状态码（status）"></a>HTTP状态码（status）</h3><ul>
<li>HTTP状态码由3位数字构成，其中首位数字定义了状态码的类型</li>
</ul>
<blockquote>
<p>1xx：信息类，表示收到Web浏览器请求，正在进一步的处理中</p>
</blockquote>
<blockquote>
<p>2xx：成功，表示用户请求被正确接收，理解和处理例如：200 OK</p>
</blockquote>
<blockquote>
<p>3xx：重定向，表示请求没有成功，客户必须采取进一步的动作</p>
</blockquote>
<blockquote>
<p>4xx：客户端错误，表示客户端提交的请求有错误，例如：404 NOT Found，意味着请求中所引用的文档不存在</p>
</blockquote>
<blockquote>
<p>5xx：服务器错误，表示服务器不能完成对请求的处理：如500</p>
</blockquote>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/hexo/page/11/"><i class="fa fa-angle-left" aria-label="Previous page"></i></a><a class="page-number" href="/hexo/">1</a><span class="space">&hellip;</span><a class="page-number" href="/hexo/page/11/">11</a><span class="page-number current">12</span><a class="page-number" href="/hexo/page/13/">13</a><a class="extend next" rel="next" href="/hexo/page/13/"><i class="fa fa-angle-right" aria-label="Next page"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="幽辰"
      src="/hexo/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">幽辰</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/hexo/archives/">
        
          <span class="site-state-item-count">127</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/hexo/categories/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">categories</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/hexo/tags/">
          
        <span class="site-state-item-count">23</span>
        <span class="site-state-item-name">tags</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">幽辰</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a>
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/hexo/lib/anime.min.js"></script>
  <script src="/hexo/lib/velocity/velocity.min.js"></script>
  <script src="/hexo/lib/velocity/velocity.ui.min.js"></script>

<script src="/hexo/js/utils.js"></script>

<script src="/hexo/js/motion.js"></script>


<script src="/hexo/js/schemes/pisces.js"></script>


<script src="/hexo/js/next-boot.js"></script>




  















  

  

</body>
</html>
